package cn.thr.ymcc.validat;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.regex.Pattern;

public class PhoneValidator implements ConstraintValidator<Phone,String> {

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        Pattern pattern = Pattern.compile("^[3-9]{1}[0-9]{9}$");
        //matcher() 用来做匹配的 自动匹配Phone 如果正确就是true 不匹配就给false
        return  pattern.matcher(s).find();
    }
}
